import request from '@/utils/http'
import { CreateWallet, UpdateWalletConfig, WalletConfig } from '@/types'
import { GetUserBalance, GetUserWalletAddress, GetWalletConfigList } from '@/api/wallet-type'

const PATH = '/wallet'

export const getBalance = () =>
	// FIXME 原钱包列表集合接口,拆分为下面3个接口; 这个接口即将删除
	request({
		/* url: PATH + '/getbalance', */
		url: PATH + '/front/wallet/userWalletList',
		method: 'get',
		params: { ts: Date.now() }
	})

export const getWalletConfigList = () =>
	request<GetWalletConfigList['result']>({
		url: PATH + '/front/wallet/configList',
		method: 'get'
	})

export const getUserBalance = (params?: GetUserBalance['params']) =>
	request<GetUserBalance['result']>({
		url: PATH + '/front/wallet/getUserBalance',
		method: 'get',
		params
	})

export const getUserWalletAddress = () =>
	request<GetUserWalletAddress['result']>({
		url: PATH + '/front/wallet/getUserWalletAddress',
		method: 'get'
	})

export const getUserWalletConfig = () =>
	request<WalletConfig>({ url: PATH + '/front/wallet/getUserWalletConfig', method: 'get' })

export const updateUserWalletConfig = <T extends keyof WalletConfig>(data: UpdateWalletConfig<T>) =>
	request({ url: PATH + '/front/wallet/updateUserWalletConfig', method: 'post', data })

export const getExchangeRate = () =>
	request({ url: '/payment/exchange-rate/quotes-all', method: 'get' })

export const getCurrencyList = () =>
	request({ url: PATH + '/front/wallet/currencyList', method: 'get' })

export const createWallet = (data: CreateWallet['params']) =>
	request({ url: PATH + '/front/wallet/createWallet', method: 'post', data })

export const getCryptoChannel = (params?: any) =>
	request({ url: `${PATH}/front/wallet/cryptoChannel`, method: 'get', params })

export const getFiatDepositChannel = (params?: any) =>
	request({ url: `${PATH}/front/wallet/fiatDepositChannel`, method: 'get', params })

export const getFiatDepositShortcutButton = (params?: any) =>
	request({ url: `${PATH}/front/wallet/fiatDepositShortcutButton`, method: 'get', params })

export const submitFiatDeposit = (data?: any) =>
	request({ url: `${PATH}/front/payment/fiatDeposit`, method: 'post', data })

export const validationCnyGb = () =>
	request({ url: `${PATH}/front/payment/validationGB`, method: 'get' })

export const getFiatWithdrawChannel = (params?: any) =>
	request({ url: `${PATH}/front/wallet/fiatWithdrawChannel`, method: 'get', params })

export const getFiatWithdrawFee = (params?: any) =>
	request({ url: `${PATH}/front/wallet/fiatWithdrawFee`, method: 'get', params })

export const submitFiatWithdraw = (data?: any) =>
	request({ url: `${PATH}/front/payment/fiatWithdraw`, method: 'post', data })

export const addCard = (data: any) => request({ url: PATH + '/addcard', method: 'post', data })

export const getAllCards = () => request({ url: PATH + '/getallcards', method: 'get' })

export const removeCard = (params: any) =>
	request({ url: PATH + '/removecard', method: 'get', params })

export const addCryptoAddress = (data: any) =>
	request({ url: PATH + '/addcryptoaddress', method: 'post', data })

export const getCryptoAddresses = () =>
	request({ url: PATH + '/getcryptoaddresses', method: 'get' })

export const removeCryptoAddress = (params: any) =>
	request({
		url: PATH + '/removecryptoaddress',
		method: 'get',
		params
	})

export const getTransactions = (params: any) =>
	request({ url: PATH + '/gettransactions', method: 'get', params })

export const getManualTransactions = (params: any) =>
	request({
		url: PATH + '/getmanualtransactions',
		method: 'get',
		params
	})

export const getDepositCryptoInfo = (data: any) =>
	request({
		url: PATH + '/getDepositCryptoInfo',
		method: 'post',
		data
	})

// /wallet/getWithdrawCryptoInfo
export const getWithdrawCryptoInfo = () =>
	request({ url: PATH + '/getWithdrawCryptoInfo', method: 'post' })

export const withdraw = (data: any) =>
	request({ url: PATH + '/front/payment/payouts', method: 'post', data })
// ({ code: 200, data: true, msg: '成功' })

export const getRechargeChannels = () =>
	request({ url: PATH + '/getrechargechannels', method: 'get' })

export const getReports = (params: any) =>
	request({ url: PATH + '/getamountchangereport', method: 'get', params })

export const downloadReports = (params: any) =>
	request({
		url: PATH + '/getamountchangereportcsv',
		method: 'get',
		params
	})

export const getBankList = () => request({ url: PATH + '/getbanklist', method: 'get' })

// new api
export const getDepositChannel = () => request({ url: PATH + '/getDepositChannel', method: 'get' })

// /wallet/getDepositFlatInfo
export const getDepositFlatInfo = (data: any) =>
	request({ url: PATH + '/getDepositFlatInfo', method: 'post', data })

export const deposit = (data: any) => request({ url: PATH + '/deposit', method: 'post', data })

export const tutorial = (data: any) => request({ url: PATH + '/getTutorial', method: 'post', data })

export const getWithdrawFlatInfo = (data: any) =>
	request({ url: PATH + '/getWithdrawFlatInfo', method: 'post', data })

export const getWithdrawChannel = () =>
	request({ url: PATH + '/getWithdrawChannel', method: 'get' })
